<template>
  <yt-page title="过程记录">
    <yt-timeLine :list="list"></yt-timeLine>
  </yt-page>
</template>

<script>
import { commonApi } from '@/common/api/commonApi.js'

export default {
  data() {
    return {
      list: []
    }
  },
  activated() {
    this.fetchData()
  },
  methods: {
    async fetchData() {
      let items = await commonApi.search('yj_information', {
        equalTo: { ids: this.$route.query.id }
      })
      let item = items[0]

      this.initList()
      this.list = this.list.filter(v => {
        switch (v.step) {
          case 1:
            return item.createTime ? (v.time = item.createTime) : false
          case 2:
            return item.programmeTime ? (v.time = item.programmeTime) : false
          case 3:
            return item.Advance ? (v.time = item.Advance) : false
          case 4:
            return item.command ? (v.time = item.command) : false
          case 5:
            return item.summaryTime ? (v.time = item.summaryTime) : false
        }
      })
    },
    initList() {
      this.list = [
        {
          time: '未定义',
          desc: '接到报警，录入事故',
          step: 1
        },
        {
          time: '未定义',
          desc: '结合事故情况，启动匹配应急预案',
          step: 2
        },
        {
          time: '未定义',
          desc: '结合事故情况，进入先期处置',
          step: 3
        },
        {
          time: '未定义',
          desc: '结合事故情况，进入指挥调度',
          step: 4
        },
        {
          time: '未定义',
          desc: '信息录入，事故总结',
          step: 5
        }
      ]

      this.list.reverse()
    }
  }
}
</script>
